package com.smarttest.common.util.protocol.ems;

import java.util.Map;

import org.slf4j.Logger;
import org.slf4j.LoggerFactory;

import com.smarttest.common.beans.protolcol.SmartMessage;
import com.smarttest.common.beans.protolcol.plv.PlvParser;
import com.smarttest.common.util.protocol.smart.SmartManager;


/**
 * @author lijinhong
 * date 2016.06.15
 */
public class EmsElectricCarParser extends EmsBaseParser{
	private SmartManager smartManager;
	private Logger log = LoggerFactory.getLogger(this.getClass());
   
    public void parse070B(SmartMessage msg) {
    	try{
    		Map<String, Object> chargingMap=this.parseTrip(msg.getData());
    		if(chargingMap==null){
    			log.warn("Smart-0x070B:解析没有数据。Imei：{}",msg.getImei());
    			return;
    		}
    		chargingMap.put("imei", msg.getImei());
    		Object obj=transferToObject(chargingMap);
    		smartManager.insertElectricCar(obj, msg.getImei());
    		log.info("Smart-0x070B:解析入MQ成功。Imei：{}",msg.getImei());
    	}catch(Exception ex){
    		log.error("Smart-0x070B-事件上报处理异常 , imei:{}", msg.getImei(),ex);
    	}
    }    
    public void setPlvParser(PlvParser plvParser) {
    	super.setPlvParser(plvParser);
	}
    
    public void setSmartManager(SmartManager smartManager) {
    	super.setSmartManager(smartManager);
        this.smartManager = smartManager;
    }
}
